<?php

class Person{

    public $name = '张三';
    private $sex = '男';
    private $age = 11;

    public function show(){
        foreach ($this as $k=>$v){
            echo $k.','.$v.PHP_EOL;
        }
    }

}

$p = new Person();

//只能遍历到能访问的属性
foreach ($p as $k=>$v){
    echo $k.','.$v.PHP_EOL;
}

//遍历所有属性
$p->show();



